package com.littleken.test;

import com.littleken.dao.UserDao;
import com.littleken.dao.impl.UserDaoImpl;
import com.littleken.entity.User;
import com.littleken.util.DBUtil;
import org.junit.Test;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class test {
   /* @Test
    public void testsqlconnection() throws SQLException {
        Connection connection = DBUtil.getConn();
        System.out.println(connection);
        String sql = "select * from user";
        PreparedStatement p = connection.prepareStatement(sql);
        ResultSet resultSet = p.executeQuery();
        User u = null;
        List<User> users = new ArrayList<>();
        while (resultSet.next()){
            Integer Id = resultSet.getInt(1);
            String Username = resultSet.getString(2);
            String Password =resultSet.getString(3);
            String Emain = resultSet.getString(4);
            String Phone = resultSet.getString(5);
            Integer Grade = resultSet.getInt(6);
            u = new User(Id,Username,Password,Emain,Phone,Grade);
            users.add(u);
        }
        System.out.println(users);
        DBUtil.close();
    }*/
   @Test
   public void testsql(){
       UserDao dao = new UserDaoImpl();
       User u = User.builder().Username("littleken").Password("123456").build();
       User user = dao.checkUser(u);
       System.out.println(user);
//       List<User> u = dao.getAllUser();
//       System.out.println(u);
   }
}
